package com.wowangz.cms.common.utils;

import java.util.Date;
import java.util.Random;

/**
 * 
 * @author yoyo
 *
 */
public class CodeCreater {

	/**
	 * 账户模块前缀
	 */
	public static class AccountCode{
		public static final String ACCOUNT_OPEN = "KH";//开户
		
		public static final String ACCOUNT_CHANGE = "BG";//变更
		
		public static final String ACCOUNT_CLOSE = "XH";//销户
	}
	
	 /**
	  * 结算模块前缀
	  */
	public static class SettlementCode{
		public static final String CUSTOMER = "KS";//客商
		
		public static final String PAY_PUBLIC = "DG";//对公
		
		public static final String PAY_PRIVATE = "DS";//对私
	}
	
	/**
	  * 监控模块前缀
	  */
	public static class MonitorCode{
		public static final String MONITORITEM = "JKCL";//监控策略
		
	}
	/**
	  * 服务购买
	  */
	public static class ServiceBuyCode{
		public static final String SERVICEBUY = "FWGM";//监控策略
		
	}
	/**
	 * 获取账户模块申请单编号
	 * @param pre
	 * @return
	 */
	public static String createAccountCode(String pre)
	{
		String result = "";
		result = DataFormat.formatDate(new Date(), DataFormat.DT_YYMMDDHHMMSS);
		return pre + result + getRandomCode();
	}
	
	/**
	 * 获取结算模块申请单编号
	 * @param pre
	 * @return
	 */
	public static String createSettlementCode(String pre)
	{
		String result = "";
		Date date = new Date();
		result = DataFormat.formatDate(date, DataFormat.DT_YYMMDDHHMMSS) + DataFormat.formatDate(date, DataFormat.DT_SSS);
		return pre + result + getRandomCode();
	}
	
	/**
	 * 获取监控模块策略编号
	 * @param pre
	 * @return
	 */
	public static String createMonitorCode(String pre)
	{
		String result = "";
		result = DataFormat.formatDate(new Date(), DataFormat.DT_YYMMDDHHMMSS);
		return pre + result + getRandomCode();
	}
	/**
	 * 获取两位随机数
	 * @return
	 */
	private static String getRandomCode()
	{
		Random random = new Random();
		return random.nextInt(10) + "" + random.nextInt(10);
	}
	
	public static void main(String[] args) {
		
		System.out.println(createAccountCode(AccountCode.ACCOUNT_CHANGE));
	}
}
